<?php
/**
 * CURL class file
 * @package Utilities
 */

/**
 * This class contains some common methods for CURL.
 * 
 * @package Utilities
 * @author Brad Dougherty <bdougherty@gmail.com>
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License 3.0
 */
class CURL {
	
	/**
	 * Returns the contents of a URL.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param string $url The url to get
	 * @return string The contents of the url
	 */
	public static function get($url) {
		$get = curl_init($url);
		curl_setopt($get, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($get, CURLOPT_TIMEOUT, 30);
		$return = curl_exec($get);
		curl_close($get);
		
		return $return;
	}
	
	/**
	 * Posts data to a page.
	 * 
	 * @author Brad Dougherty <bdougherty@gmail.com>
	 * @param string $url The url to post
	 * @param string $params The values to post
	 * @return string The contents of the url
	 */
	public static function post($url, $params) {
		$post = curl_init($url);
		curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($post, CURLOPT_TIMEOUT, 30);
		curl_setopt($post, CURLOPT_POST, 1);
		curl_setopt($post, CURLOPT_POSTFIELDS, $params);
		$return = curl_exec($post);
		curl_close($post);
		
		return $return;
	}
	
}

?>